home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Lists / ListHead.h < prev    next >
Encoding:
Text File  |  1997-06-28  |  1.2 KB  |  64 lines  |  [TEXT/CWIE]

  1. // ListHead.h
  2.  
  3. #ifndef ListHead_h
  4. #define ListHead_h
  5.  
  6. #ifndef Integers_h
  7. #include "Integers.h"
  8. #endif
  9. #ifndef Assert_h
  10. #include "Assert.h"
  11. #endif
  12. #ifndef Prepositions_h
  13. #include "Prepositions.h"
  14. #endif
  15.  
  16. template < class Element > class ListLink;
  17. template < class Element > class ListLoop;
  18.  
  19. template < class Element >
  20. class ListHead
  21.   {
  22.     typedef ListLink< Element > Link;
  23.     typedef ListHead< Element > Head;
  24.     typedef ListLoop< Element > Loop;
  25.  
  26.     friend class ListLoop< Element >;
  27.     
  28.     private:
  29.         Link *first;
  30.         Link *last;
  31.     
  32.         Loop *firstLoop;    /* mutable */
  33.         
  34.         void Register( Loop& ) const;
  35.         void Unregister( Loop& ) const;
  36.         
  37.         // not implemented:
  38.             ListHead( const ListHead& );
  39.             void operator=( const ListHead& );
  40.         
  41.     public:
  42.         ListHead();
  43.         ~ListHead();
  44.         
  45.         Link *First() const            { return first; }
  46.         Link *Last() const            { return last; }
  47.         
  48.         bool IsEmpty() const            { return first == 0; }
  49.         
  50.         void Add( Link&, BeforeStart );
  51.         void Add( Link&, AfterEnd );
  52.         
  53.         void Add( Link&, Before, const Link& position );
  54.         void Add( Link&, After, const Link& position );
  55.         
  56.         void Add( Link&, Before, const Loop& position );
  57.         void Add( Link&, After, const Loop& position );
  58.         
  59.         void Remove( Link& );
  60.         void RemoveAll();
  61.   };
  62.  
  63. #endif
  64.